#include "showtable.h"

ShowTable::ShowTable(QObject *parent) : QObject(parent)
{

}

void ShowTable::logtoolsSwitchTable(QList<QMap<QString, QString> > &logList, QTableView *ShowTable, QStandardItemModel *model)
{
    //清空表格
    model->clear();

    //设置表头
    model->setHorizontalHeaderLabels(QStringList()<<"日期"<<"时间"<<"动作");
    //显示内容
    for (int i=0; i<logList.size(); i++) {
        for (QMap<QString, QString>::ConstIterator mapj=logList.at(i).constBegin(); mapj!=logList.at(i).constEnd(); mapj++) {
            if (mapj.key() == "日期") {
                model->setItem(i, 0, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "时间") {
                model->setItem(i, 1, new QStandardItem(mapj.value()));
            }
            else {
                model->setItem(i, 2, new QStandardItem(mapj.value()));
            }
        }
    }
    ShowTable->setModel(model);
}

void ShowTable::logtoolsSysInfoTable(QList<QMap<QString, QString> > &logList, QTableView *ShowTable, QStandardItemModel *model)
{
    model->clear();
    model->setHorizontalHeaderLabels(QStringList()<<"日期"<<"时间"<<"主机名"<<"动作"<<"描述");

    for (int i=0; i<logList.size(); i++) {
        for (QMap<QString, QString>::ConstIterator mapj=logList.at(i).constBegin(); mapj!=logList.at(i).constEnd(); mapj++) {
            if (mapj.key() == "日期") {
                model->setItem(i, 0, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "时间") {
                model->setItem(i, 1, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "主机名") {
                model->setItem(i, 2, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "动作") {
                model->setItem(i, 3, new QStandardItem(mapj.value()));
            }
            else {
                model->setItem(i, 4, new QStandardItem(mapj.value()));
            }
        }
    }
    ShowTable->setModel(model);
}

void ShowTable::logtoolsSysBootTable(QList<QMap<QString, QString> > &logList, QTableView *ShowTable, QStandardItemModel *model)
{
    model->clear();
    model->setHorizontalHeaderLabels(QStringList()<<"动作"<<"描述");

    for (int i=0; i<logList.size(); i++) {
        for (QMap<QString, QString>::ConstIterator mapj=logList.at(i).constBegin(); mapj!=logList.at(i).constEnd(); mapj++) {
            if (mapj.key() == "动作") {
                model->setItem(i, 0, new QStandardItem(mapj.value()));
            }
            else {
                model->setItem(i, 1, new QStandardItem(mapj.value()));
            }
        }
    }
    ShowTable->setModel(model);
}

void ShowTable::logtoolsPackageTable(QList<QMap<QString, QString> > &logList, QTableView *ShowTable, QStandardItemModel *model)
{
    model->clear();
    model->setHorizontalHeaderLabels(QStringList()<<"日期"<<"时间"<<"状态"<<"软件包");

    for (int i=0; i<logList.size(); i++) {
        for (QMap<QString, QString>::ConstIterator mapj=logList.at(i).constBegin(); mapj!=logList.at(i).constEnd(); mapj++) {
            if (mapj.key() == "日期") {
                model->setItem(i, 0, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "时间") {
                model->setItem(i, 1, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "状态") {
                model->setItem(i, 2, new QStandardItem(mapj.value()));
            }
            else {
                model->setItem(i, 3, new QStandardItem(mapj.value()));
            }
        }
    }
    ShowTable->setModel(model);
}

void ShowTable::logtoolsKernelTable(QList<QMap<QString, QString> > &logList, QTableView *ShowTable, QStandardItemModel *model)
{
    model->clear();
    model->setHorizontalHeaderLabels(QStringList()<<"日期"<<"时间"<<"主机名"<<"描述");

    for (int i=0; i<logList.size(); i++) {
        for (QMap<QString, QString>::ConstIterator mapj=logList.at(i).constBegin(); mapj!=logList.at(i).constEnd(); mapj++) {
            if (mapj.key() == "日期") {
                model->setItem(i, 0, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "时间") {
                model->setItem(i, 1, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "主机名") {
                model->setItem(i, 2, new QStandardItem(mapj.value()));
            }
            else {
                model->setItem(i, 3, new QStandardItem(mapj.value()));
            }
        }
    }
    ShowTable->setModel(model);
}

void ShowTable::logtoolsSoftwareUpdateTable(QList<QMap<QString, QString> > &logList, QTableView *ShowTable, QStandardItemModel *model)
{
    model->clear();
    model->setHorizontalHeaderLabels(QStringList()<<"日期"<<"时间"<<"描述");

    for (int i=0; i<logList.size(); i++) {
        for (QMap<QString, QString>::ConstIterator mapj=logList.at(i).constBegin(); mapj!=logList.at(i).constEnd(); mapj++) {
            if (mapj.key() == "日期") {
                model->setItem(i, 0, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "时间") {
                model->setItem(i, 1, new QStandardItem(mapj.value()));
            }
            else {
                model->setItem(i, 2, new QStandardItem(mapj.value()));
            }
        }
    }
    ShowTable->setModel(model);
}

void ShowTable::logtoolsPrintTable(QList<QMap<QString, QString> > &logList, QTableView *ShowTable, QStandardItemModel *model)
{
    model->clear();
    model->setHorizontalHeaderLabels(QStringList()<<"日期"<<"时间"<<"主机名"<<"用户"<<"动作"<<"描述");

    for (int i=0; i<logList.size(); i++) {
        for (QMap<QString, QString>::ConstIterator mapj=logList.at(i).constBegin(); mapj!=logList.at(i).constEnd(); mapj++) {
            if (mapj.key() == "日期") {
                model->setItem(i, 0, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "时间") {
                model->setItem(i, 1, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "主机名") {
                model->setItem(i, 2, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "用户") {
                model->setItem(i, 3, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "动作") {
                model->setItem(i, 4, new QStandardItem(mapj.value()));
            }
            else {
                model->setItem(i, 5, new QStandardItem(mapj.value()));
            }
        }
    }
    ShowTable->setModel(model);
}

void ShowTable::logtoolsBurnTable(QList<QMap<QString, QString> > &logList, QTableView *ShowTable, QStandardItemModel *model)
{
    model->clear();
    model->setHorizontalHeaderLabels(QStringList()<<"描述");

    for (int i=0; i<logList.size(); i++) {
        for (QMap<QString, QString>::ConstIterator mapj=logList.at(i).constBegin(); mapj!=logList.at(i).constEnd(); mapj++) {
            model->setItem(i, 0, new QStandardItem(mapj.value()));
        }
    }
    ShowTable->setModel(model);
}

void ShowTable::logtoolsAuditTable(QList<QMap<QString, QString> > &logList, QTableView *ShowTable, QStandardItemModel *model)
{
    model->clear();
    model->setHorizontalHeaderLabels(QStringList()<<"描述");

    for (int i=0; i<logList.size(); i++) {
        for (QMap<QString, QString>::ConstIterator mapj=logList.at(i).constBegin(); mapj!=logList.at(i).constEnd(); mapj++) {
            model->setItem(i, 0, new QStandardItem(mapj.value()));
        }
    }
    ShowTable->setModel(model);
}

void ShowTable::logtoolsSessionTable(QList<QMap<QString, QString> > &logList, QTableView *ShowTable, QStandardItemModel *model)
{
    model->clear();
    model->setHorizontalHeaderLabels(QStringList()<<"描述");

    for (int i=0; i<logList.size(); i++) {
        for (QMap<QString, QString>::ConstIterator mapj=logList.at(i).constBegin(); mapj!=logList.at(i).constEnd(); mapj++) {
            model->setItem(i, 0, new QStandardItem(mapj.value()));
        }
    }
    ShowTable->setModel(model);
}

void ShowTable::logtoolsXorgTable(QList<QMap<QString, QString> > &logList, QTableView *ShowTable, QStandardItemModel *model)
{
    model->clear();
    model->setHorizontalHeaderLabels(QStringList()<<"加载时间"<<"描述");

    for (int i=0; i<logList.size(); i++) {
        for (QMap<QString, QString>::ConstIterator mapj=logList.at(i).constBegin(); mapj!=logList.at(i).constEnd(); mapj++) {
            if (mapj.key() == "加载时间") {
                model->setItem(i, 0, new QStandardItem(mapj.value()));
            }
            else {
                model->setItem(i, 1, new QStandardItem(mapj.value()));
            }
        }
    }
    ShowTable->setModel(model);
}

void ShowTable::logtoolsApplicationTable(QList<QMap<QString, QString> > &logList, QTableView *ShowTable, QStandardItemModel *model)
{
    model->clear();
    model->setHorizontalHeaderLabels(QStringList()<<"日期"<<"时间"<<"来源"<<"信息");

    for (int i=0; i<logList.size(); i++) {
        for (QMap<QString, QString>::ConstIterator mapj=logList.at(i).constBegin(); mapj!=logList.at(i).constEnd(); mapj++) {
            if (mapj.key() == "日期") {
                model->setItem(i, 0, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "时间") {
                model->setItem(i, 1, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "来源") {
                model->setItem(i, 2, new QStandardItem(mapj.value()));
            }
            else {
                model->setItem(i, 3, new QStandardItem(mapj.value()));
            }
        }
    }
    ShowTable->setModel(model);
}

void ShowTable::logtoolsSwitchTimesTable(QList<QMap<QString, QString> > &logList, QTableView *ShowTable, QStandardItemModel *model)
{
    model->clear();
    model->setHorizontalHeaderLabels(QStringList()<<"年份"<<"月份"<<"登录次数"<<"开机次数"<<"关机次数");

    for (int i=0; i<logList.size(); i++) {
        for (QMap<QString, QString>::ConstIterator mapj=logList.at(i).constBegin(); mapj!=logList.at(i).constEnd(); mapj++) {
            if (mapj.key() == "年份") {
                model->setItem(i, 0, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "月份") {
                model->setItem(i, 1, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "登录次数") {
                model->setItem(i, 2, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "开机次数") {
                model->setItem(i, 3, new QStandardItem(mapj.value()));
            }
            else {
                model->setItem(i, 4, new QStandardItem(mapj.value()));
            }
        }
    }
    ShowTable->setModel(model);
}

void ShowTable::logtoolsDebugTable(QList<QMap<QString, QString> > &logList, QTableView *ShowTable, QStandardItemModel *model)
{
    model->clear();
    model->setHorizontalHeaderLabels(QStringList()<<"日期"<<"时间"<<"主机名"<<"动作"<<"描述");
    for (int i=0; i<logList.size(); i++) {
        for (QMap<QString, QString>::ConstIterator mapj=logList.at(i).constBegin(); mapj!=logList.at(i).constEnd(); mapj++) {
            if (mapj.key() == "日期") {
                model->setItem(i, 0, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "时间") {
                model->setItem(i, 1, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "主机名") {
                model->setItem(i, 2, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "动作") {
                model->setItem(i, 3, new QStandardItem(mapj.value()));
            }
            else {
                model->setItem(i, 4, new QStandardItem(mapj.value()));
            }
        }
    }
    ShowTable->setModel(model);
}

void ShowTable::logtoolsInfoTable(QList<QMap<QString, QString> > &logList, QTableView *ShowTable, QStandardItemModel *model)
{
    model->clear();
    model->setHorizontalHeaderLabels(QStringList()<<"日期"<<"时间"<<"主机名"<<"动作"<<"描述");
    for (int i=0; i<logList.size(); i++) {
        for (QMap<QString, QString>::ConstIterator mapj=logList.at(i).constBegin(); mapj!=logList.at(i).constEnd(); mapj++) {
            if (mapj.key() == "日期") {
                model->setItem(i, 0, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "时间") {
                model->setItem(i, 1, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "主机名") {
                model->setItem(i, 2, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "动作") {
                model->setItem(i, 3, new QStandardItem(mapj.value()));
            }
            else {
                model->setItem(i, 4, new QStandardItem(mapj.value()));
            }
        }
    }
    ShowTable->setModel(model);
}

void ShowTable::logtoolsNoticeTable(QList<QMap<QString, QString> > &logList, QTableView *ShowTable, QStandardItemModel *model)
{
    model->clear();
    model->setHorizontalHeaderLabels(QStringList()<<"日期"<<"时间"<<"主机名"<<"动作"<<"描述");
    for (int i=0; i<logList.size(); i++) {
        for (QMap<QString, QString>::ConstIterator mapj=logList.at(i).constBegin(); mapj!=logList.at(i).constEnd(); mapj++) {
            if (mapj.key() == "日期") {
                model->setItem(i, 0, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "时间") {
                model->setItem(i, 1, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "主机名") {
                model->setItem(i, 2, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "动作") {
                model->setItem(i, 3, new QStandardItem(mapj.value()));
            }
            else {
                model->setItem(i, 4, new QStandardItem(mapj.value()));
            }
        }
    }
    ShowTable->setModel(model);
}

void ShowTable::logtoolsWarningTable(QList<QMap<QString, QString> > &logList, QTableView *ShowTable, QStandardItemModel *model)
{
    model->clear();
    model->setHorizontalHeaderLabels(QStringList()<<"日期"<<"时间"<<"主机名"<<"动作"<<"描述");
    for (int i=0; i<logList.size(); i++) {
        for (QMap<QString, QString>::ConstIterator mapj=logList.at(i).constBegin(); mapj!=logList.at(i).constEnd(); mapj++) {
            if (mapj.key() == "日期") {
                model->setItem(i, 0, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "时间") {
                model->setItem(i, 1, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "主机名") {
                model->setItem(i, 2, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "动作") {
                model->setItem(i, 3, new QStandardItem(mapj.value()));
            }
            else {
                model->setItem(i, 4, new QStandardItem(mapj.value()));
            }
        }
    }
    ShowTable->setModel(model);
}

void ShowTable::logtoolsErrorTable(QList<QMap<QString, QString> > &logList, QTableView *ShowTable, QStandardItemModel *model)
{
    model->clear();
    model->setHorizontalHeaderLabels(QStringList()<<"日期"<<"时间"<<"主机名"<<"动作"<<"描述");
    for (int i=0; i<logList.size(); i++) {
        for (QMap<QString, QString>::ConstIterator mapj=logList.at(i).constBegin(); mapj!=logList.at(i).constEnd(); mapj++) {
            if (mapj.key() == "日期") {
                model->setItem(i, 0, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "时间") {
                model->setItem(i, 1, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "主机名") {
                model->setItem(i, 2, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "动作") {
                model->setItem(i, 3, new QStandardItem(mapj.value()));
            }
            else {
                model->setItem(i, 4, new QStandardItem(mapj.value()));
            }
        }
    }
    ShowTable->setModel(model);
}

void ShowTable::logtoolsCriticalTable(QList<QMap<QString, QString> > &logList, QTableView *ShowTable, QStandardItemModel *model)
{
    model->clear();
    model->setHorizontalHeaderLabels(QStringList()<<"日期"<<"时间"<<"主机名"<<"动作"<<"描述");
    for (int i=0; i<logList.size(); i++) {
        for (QMap<QString, QString>::ConstIterator mapj=logList.at(i).constBegin(); mapj!=logList.at(i).constEnd(); mapj++) {
            if (mapj.key() == "日期") {
                model->setItem(i, 0, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "时间") {
                model->setItem(i, 1, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "主机名") {
                model->setItem(i, 2, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "动作") {
                model->setItem(i, 3, new QStandardItem(mapj.value()));
            }
            else {
                model->setItem(i, 4, new QStandardItem(mapj.value()));
            }
        }
    }
    ShowTable->setModel(model);
}

void ShowTable::logtoolsAlertTable(QList<QMap<QString, QString> > &logList, QTableView *ShowTable, QStandardItemModel *model)
{
    model->clear();
    model->setHorizontalHeaderLabels(QStringList()<<"日期"<<"时间"<<"主机名"<<"动作"<<"描述");
    for (int i=0; i<logList.size(); i++) {
        for (QMap<QString, QString>::ConstIterator mapj=logList.at(i).constBegin(); mapj!=logList.at(i).constEnd(); mapj++) {
            if (mapj.key() == "日期") {
                model->setItem(i, 0, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "时间") {
                model->setItem(i, 1, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "主机名") {
                model->setItem(i, 2, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "动作") {
                model->setItem(i, 3, new QStandardItem(mapj.value()));
            }
            else {
                model->setItem(i, 4, new QStandardItem(mapj.value()));
            }
        }
    }
    ShowTable->setModel(model);
}

void ShowTable::logtoolsEmergTable(QList<QMap<QString, QString> > &logList, QTableView *ShowTable, QStandardItemModel *model)
{
    model->clear();
    model->setHorizontalHeaderLabels(QStringList()<<"日期"<<"时间"<<"主机名"<<"动作"<<"描述");
    for (int i=0; i<logList.size(); i++) {
        for (QMap<QString, QString>::ConstIterator mapj=logList.at(i).constBegin(); mapj!=logList.at(i).constEnd(); mapj++) {
            if (mapj.key() == "日期") {
                model->setItem(i, 0, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "时间") {
                model->setItem(i, 1, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "主机名") {
                model->setItem(i, 2, new QStandardItem(mapj.value()));
            }
            else if (mapj.key() == "动作") {
                model->setItem(i, 3, new QStandardItem(mapj.value()));
            }
            else {
                model->setItem(i, 4, new QStandardItem(mapj.value()));
            }
        }
    }
    ShowTable->setModel(model);
}
